package org.dromara.business.sensitive;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws IOException {

        List<String> datas = Files.lines(Path.of("F:\\web\\bb\\bb-backend\\bb-modules\\bb-business\\src\\main\\resources\\sensitive_words_lines.txt")).collect(Collectors.toList());

        SensitiveFilter filter = new SensitiveFilter(datas);

        // 测试用例 1：相同的词多次出现
        String text1 = "高能预警";
        runTest(filter, text1);
    }

    private static void runTest(SensitiveFilter filter, String text) {
        System.out.println("原文本: " + text);
        System.out.println("命中词: " + filter.getMatchedWords(text));
        System.out.println("详细命中: " + filter.detail(text));
        System.out.println("过滤后: " + filter.replace(text, '*'));
        System.out.println("--------------------------------------------------");
    }
}
